from odoo import models, _
from odoo.exceptions import UserError


class MrpWorkorder(models.Model):
    _inherit = 'mrp.workorder'

    def button_start(self):
        if self.env['ir.config_parameter'].sudo().get_param('pcb.s_during_the_inventory_period'):
            raise UserError(_('During the system inventory period, production reporting is not allowed!'))
        return super().button_start()

    def button_finish(self):
        if self.env['ir.config_parameter'].sudo().get_param('pcb.s_during_the_inventory_period'):
            raise UserError(_('During the system inventory period, production reporting is not allowed!'))
        return super().button_finish()

    def chargeback(self):
        if self.env['ir.config_parameter'].sudo().get_param('pcb.s_during_the_inventory_period'):
            raise UserError(_('During the system inventory period, production reporting is not allowed!'))
        return super().chargeback()